//
// Created by fanghr on 17-12-24.
//

#ifndef PROJECT_IMU_PRESSUREANDHEIGHTOUTPUT_H
#define PROJECT_IMU_PRESSUREANDHEIGHTOUTPUT_H

#include "../../include.h"

class imu_pressureAndHeightOutput {
public:
    struct table_t {
        friend class boost::serialization::access;

        uint32_t p, h;

        template<class Archive>
        void serialize(Archive &ar, const unsigned int) {
            ar & p;
            ar & h;
        }
    };

private:
    friend class boost::serialization::access;

    template<class Archive>
    void serialize(Archive &ar, const unsigned int) {
        ar & table;
    }

    table_t table;
public:
    imu_pressureAndHeightOutput() {}

    imu_pressureAndHeightOutput(boost::array<uint8_t, 9> raw) {
        table.h = (uint32_t) ((raw.at(3) << 24) | (raw.at(2) << 16) | (raw.at(1) << 8) | raw.at(0));
        table.h = (uint32_t) ((raw.at(7) << 24) | (raw.at(6) << 16) | (raw.at(5) << 8) | raw.at(4));
    }

    table_t get() {
        return table;
    }
};


#endif //PROJECT_IMU_PRESSUREANDHEIGHTOUTPUT_H
